package com.iglooit.components.gui
{
	import spark.components.TextArea;
	
	public class XMLTextArea extends TextArea implements IXMLComponent
	{
		protected var _xml:XML;
		protected var _nodeName:String;
		protected var _nodeValue:String
		protected var _attributes:Object;
		
		public function XMLTextArea()
		{
			super();
			this._xml=new XML();
		}
		
		public function get xml():XML
		{
			return this._xml;
		}
		
		public function set xml(value:XML):void
		{
			this._xml=value;
			this.text=value;
		}
		
		public function set attributes(value:Object):void
		{
			this._attributes = value;
		}
		
		public function submit():void
		{
			var textinputXML:XML=<{this._nodeName}>
			{this._nodeValue != null ? this._nodeValue : this.text}
			</{this._nodeName}>;
			for (var key:String in this._attributes)
			{
				textinputXML.@[key]=this._attributes[key];
			}
			this._xml=textinputXML;
		}
		
		public function set nodeValue(value:String):void
		{
			this._nodeValue=value;
		}
		
		public function set nodeName(value:String):void
		{
			this._nodeName=value;
		}
	}
}